package com.control 
{
	import com.data.GameData;
	import components.Singleton;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.utils.Dictionary;
	/**
	 * ...
	 * @author wen
	 */
	public class LayerManager extends Singleton
	{
		public static const MENU:String = "menu";
		public static const MAP:String 	= "map";
		public static const DILOG:String = "dilog";
		public static const LOADING:String = "loading";
		public static const DEBUG:String = "debug";
		
		private var _layerArray:Array = null;
		
		private var _layerDic:Dictionary = null;
		
		
		public function LayerManager() 
		{
			init();
		}
		
		private function init():void
		{
			_layerArray = ["map", "dilog", "menu", "loading","debug"];
			
			_layerDic = new Dictionary();
			
			for (var i:int = 0; i < _layerArray.length; i++ )
			{
				_layerDic[(_layerArray[i] as String)] = new Sprite();
				GameData.stage.addChild( _layerDic[(_layerArray[i] as String)]);
			}
		}
		
		/**
		 * 
		 * @param	mc
		 * @param	layer
		 */
		public function addToLayer(mc:DisplayObject,layer:String):void
		{
			if (!mc) return;
			if (_layerArray.indexOf(layer) == -1) return;
			
			(_layerDic[layer] as Sprite).addChild(mc);
		}
		
		public static function get instance():LayerManager
		{
			return Singleton.getInstance(LayerManager) as LayerManager;
		}
	}

}